declare namespace h = "http://www.w3.org/1999/xhtml";
declare namespace xf = "http://www.w3.org/2002/xforms";
declare namespace xs = "http://www.w3.org/2001/XMLSchema";
import module namespace common = "http://www.metaphoricalweb.com/xmlns/common" at "common.xq";

let $opt := (util:declare-option("exist:serialize", "media-type=text/xml"))
let $id := common:get-parameter("id","new.xml")
let $type := common:get-parameter("type","cv")
let $editor := doc(concat("/db/xrai/",$type,"/views/editor.xml"))
let $path := if ($id = "new") then
        concat("/exist/rest//db/xrai/common/xq/getnew.xq?type=",$type,";format=xml")
    else
        concat("/exist/rest//db/xrai/common/xq/getbyid.xq?id=",$id,";format=xml")
(: Aleria Delamare      0F5530EA-20A8-CC34-0E32-52EE1FB0BCB8   :)
let $node := $editor//xf:instance[@id='data-instance']
let $update := (update value $node/@src with $path)
return $editor
